package com.leetcode.math;

/**
 * @author Dennis Li
 * @date 2020/7/29 22:19
 */
public class BaseSeven_504 {

    public String convertToBase7(int num) {
        if (num == 0) return "0";
        return num < 0 ? "-" + convert(-num) : convert(num);
    }

    public String convert(int num) {
        if (num == 0) return "";
        return convert(num / 7) + (num % 7);
    }

}
